home *** CD-ROM | disk | FTP | other *** search
/ Stone Design / Stone Design.iso / Stone_Friends / Wave / WavesWorld / Source / IBPalettes / WW3DKit / RIBPolygon.m < prev    next >
Encoding:
Text File  |  1995-03-22  |  2.1 KB  |  107 lines

  1. // copyright 1993 Michael B. Johnson; some portions copyright 1994, MIT
  2. // see COPYRIGHT for reuse legalities
  3. //
  4.  
  5. #import "RIBPolygon.h"
  6.  
  7.  
  8. @implementation RIBPolygon
  9.  
  10. + initialize { return [RIBPolygon setVersion:1], self; }
  11.  
  12. - (BOOL)hasBoundingBox { return YES; }
  13.  
  14. - init
  15. {
  16.   [super init];
  17.  
  18.   nVertices = 0;
  19.  
  20.   return self;
  21. }
  22.  
  23. - setNVertices:(RtInt)newNVertices 
  24.      n:(int)newN tokens:(RtToken *)newTokens parms:(RtPointer *)newParms archiveVector:(char **)newArchiveVector
  25.      printfTypeVector:(int *)newPrintfTypeVector printfNVector:(int *)newPrintfNVector
  26. {  
  27.    nVertices = newNVertices;
  28.    howManyPoints = nVertices;
  29.    [self setN:newN tokens:newTokens parms:newParms archiveVector:newArchiveVector printfTypeVector:newPrintfTypeVector printfNVector:newPrintfNVector];
  30.  
  31.    dirtyBoundingBox = TRUE;
  32.    return self;
  33. }
  34.  
  35. - setNVertices:(RtInt)newNVertices { nVertices = newNVertices; dirtyBoundingBox = TRUE; return self; }
  36.  
  37. - (RtInt)nVertices { return nVertices; }
  38. - (int)n { return n; }
  39. - (RtToken *)tokens { return tokens; }
  40. - (RtPointer *)parms { return parms; }
  41.  
  42.  
  43. - (BOOL)theSameAs:otherRIBCommand
  44. {
  45.   if (nVertices != [otherRIBCommand nVertices])
  46.   {  return NO;
  47.   }
  48.  
  49.   return [super theSameAs:otherRIBCommand];
  50. }
  51.  
  52.  
  53. - renderSelf:(WW3DCamera *)camera startingAt:(RtFloat)shutterOpenTime endingAt:(RtFloat)shutterCloseTime
  54. {
  55.   RiPolygonV(nVertices, n, tokens, parms);
  56.   return self;
  57. }
  58.  
  59.  
  60. - (BOOL)isMotionBlurrable { return YES; }
  61.  
  62. - writeEve:(NXStream *)stream atTabLevel:(int)tab
  63. {
  64.    int  i;
  65.  
  66.  
  67.    for (i = 0; i < tab; i++)
  68.    {  NXPrintf(stream, "\t");
  69.    }
  70.    NXPrintf(stream, "Polygon ");
  71.    [super writeParameterList:stream];
  72.    return self;
  73. }
  74.  
  75. #define typeVector "i"
  76. #define typeValues &nVertices
  77.  
  78. - read:(NXTypedStream*)stream 
  79. {
  80.     int version;
  81.  
  82.  
  83.     [super read:stream];
  84.  
  85.     version = NXTypedStreamClassVersion(stream,"RIBPolygon");
  86.     if (version == 0) NXReadTypes(stream,"i",&version), version=1;
  87.     if (version == 1)
  88.     {  NXReadTypes(stream,typeVector,typeValues);
  89.     } 
  90.     else 
  91.     {
  92.     }
  93.     return self;
  94. }
  95.  
  96. - write:(NXTypedStream*)stream 
  97. {
  98.     [super write:stream];
  99.  
  100.     NXWriteTypes(stream,typeVector, typeValues);
  101.  
  102.     return self;
  103. }
  104.  
  105.  
  106. @end
  107.